package controllers

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"mon-go-web/internal/models"
	"mon-go-web/internal/services"
	"mon-go-web/pkg/logger"
	"mon-go-web/pkg/response"
)

type ArticleController struct {
	articleService *services.ArticleService
}

func NewArticleController() *ArticleController {
	return &ArticleController{articleService: services.NewArticleService()}
}

func (c *ArticleController) Create(ctx *gin.Context, article *models.Article) {
	logger.Logger.Info("Creating article", zap.Any("article", article))
	rows := c.articleService.Create(article)
	response.Success(ctx, rows)
}

func (c *ArticleController) GetByQuery(ctx *gin.Context, query *models.Article) {
	logger.Logger.Info("Articles retrieved by query", zap.Any("query", query))
	articles := c.articleService.GetAll()
	response.Success(ctx, articles)
}
